

function savedex(dexbytes,dexpath) {
Java.perform(function () {

    var FileOutputStream = Java.use("java.io.FileOutputStream");
    var File = Java.use("java.io.File");
    var fileobj = File.$new(dexpath);
    var fileoutputobj = FileOutputStream.$new(fileobj);
    fileoutputobj.write(dexbytes);
    fileoutputobj.close();



})
}


function fdex2(className) {

    Java.perform(function () {

        Java.enumerateClassLoadersSync().forEach(function (loader) {
            
            try {

                // var className="com.android.dex.Dex"; // getBytes getDex


                var ThisClass = loader.loadClass(className);
                console.log("classcloader:\t"+JSON.stringify(loader));

                // var Class = Java.use("java.lang.Class");
                // var getDex = Class.getDex();
                // var Dex = Java.use("com.android.dex.Dex");
                var dexobj = ThisClass.getDex();
                var dexbytearray = dexobj.getBytes();
            //     将 byte数组保存到文件
                var dexpath="/sdcard/"+className+"1.dex"
                savedex(dexbytearray,dexpath);
                console.log("[dumdex] ok:\t");
            }catch (e) {

            }

        })
    })
}


// setTimeout(fdex2)
// 通过已知的类脱壳
// fs1\fdex2.js
// frida -H 127.0.0.1:8888 -f com.google.android.apps.maps  -l fdex2.js --no-pause


// fdex2("com.google.android.maps.MapsActivity")